<template>
	<view class="deta">
		   
			<view class="job_top">
				<text class="professionName same">{{jobpostlist.name}}</text>
				<text class="tak">{{jobpostlist.salary}}元/月</text>
			</view>
			
			<view class="job_min same">
				<uni-section title="任职要求" type="line" padding>
				<text>{{jobpostlist.need}}</text>
				</uni-section>
			</view>
			
			
			<view class="job_minn same">
				<uni-section title="职位描述" type="line" padding>
				<text class="obligation">{{jobpostlist.obligation}}</text>
			</uni-section>
			</view>
			
			
			<view class="job_last same">
				<uni-section title="工作地点" type="line" padding>
				<text class="contacts">{{jobpostlist.address}}</text>
				<view class="page-section page-section-gap">
				<map tyle="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude"></map>
				</view>
				</uni-section>
			</view>
			
			<view class="send">
				<u-icon name="list" labelPos='bottom' color="#f56c6c" labelColor="#f56c6c" labelSize='14'  label='投递列表' size="20" @click='gosendli' />
				<up-button type="primary" text="投递简历" @click='senddate'></up-button>
			</view>
		
	</view>
</template>

<script setup>
import { getCurrentInstance, onBeforeMount, onMounted, ref } from 'vue'
import {getjobpost,godeliver} from '../../../api/jobApi.js'
import {sametime} from '../../../untils/globeTime.js'
import {comlist} from '@/mock/work.js'
import {onLoad} from '@dcloudio/uni-app'

const id =ref()     //传过来的岗位id
const comid =ref()  //传过来的公司id
const jobpostlist=ref({})  //详细信息
const latitude=ref() //经度
const longitude=ref() //维度


//点击投递列表跳转
const gosendli=()=>{
	
	uni.navigateTo({
		url:"/pages/job/notes/notes"
	})
}

//点击投递简历
const senddate=async()=>{
	
	let nowtime = sametime()

	let  res = await godeliver({
		header:{
			'Authorization':uni.getStorageSync('token')
		},
		data:{
		companyId:comid.value,
		postId:id.value,
		postName:jobpostlist.value.name,
	    satrTime:nowtime
		}
	})
	
	if(res.code==200){
		uni.showToast({
			title:'投递成功',
			duration: 1000
		})
	}else{
		//模拟数据
		uni.showToast({
			title:'投递成功',
			duration: 1000
		})
	}
	
}

//获取招聘信息详情
const getjobdata=async()=>{

	// id.value=getCurrentInstance().attrs.id
	// comid.value=getCurrentInstance().attrs.comid
	
	let res =await getjobpost({
		id:id.value,
		data:{}
	})
	if(res.code==200){
		jobpostlist.value=res.data
	}else{
		//静态数据
		uni.getLocation({
			type: 'wgs84',
				success: function (res) {
					console.log('当前位置的经度：' + res.longitude);
					console.log('当前位置的纬度：' + res.latitude);
					
					latitude.value=res.latitude
					longitude.value=res.longitude
					
				}
		})
		
		jobpostlist.value=comlist(comid.value)[0]
		
		
	}
	console.log(jobpostlist.value);
}


onLoad((option)=>{
	id.value=option.id
	comid.value=option.comid
	getjobdata()
	
})

// onMounted(()=>{
// 	getjobdata()
// })

</script>
<style lang="scss">
	.deta{
		width: 100%;
		
		overflow: hidden;
		background-color: rgb(237, 241, 248);
		
		.same{
			margin: 5px;
		}
		
	
		.job_top{
			display: flex;
			justify-content: space-between;
			align-items: center;
			 background-color:#fff;
			 border-radius: 10px;
			 margin: 10px;
			 padding:16px 10px ;
			 
			.professionName{
				font-weight: 700;
				font-size: 18px;
			}
			.tak{
				color: royalblue;
				font-size: 16px;
			}
			
		}	
		.job_min{
			display: flex;
			justify-content: space-between;
			background-color:#fff;
			border-radius: 10px;
			margin: 10px;
			padding:16px 10px ;
		}
		.job_minn{
			background-color:#fff;
			border-radius: 10px;
			margin: 10px;
			padding:16px 10px ;
			color:#8e9091 ;
			
			.obligation{
			padding-bottom: 10px;
			}
		}
		.job_last{
			display: flex;
			justify-content: space-between;
		    align-items: center;
			background-color:#fff;
			border-radius: 10px;
			margin: 10px;
			padding:16px 10px ;
			.uni-section{
				
			map{
				margin-top: 10px;
			}
				
			}
		}
		.send{
		   margin:5px 10px;
		   display: flex;
		   .u-icon{
			   margin-right: 10px;
		   }
		}
		
	}

</style>
